<?php

namespace App\Models;

use Illuminate\Database\Eloquent\Factories\HasFactory;
use Illuminate\Database\Eloquent\Model;

class GoodsOrder extends Model
{
    const TYPE = [ '0' => '资料', '1' => '节点', '2' => '产品'];
    public $timestamps = false;
    protected $connection = 'xz';
    protected $table = 'goods_order';
    use HasFactory;

    public function getCreateTimeAttribute(string $value)
    {
        return Date("Y-m-d H:i:s",$value);
    }

    public function getTypeAttribute(string $value)
    {
        return self::TYPE[$value];
    }

    public function information()
    {
        return $this->hasOne('App\Models\Information','id','source_id');
    }

    public function node()
    {
        return $this->hasOne('App\Models\Node','id','source_id');
    }
}
